﻿using SD.Infrastructure.AppServiceBase;
using SD.Infrastructure.DTOBase;
using SD.OpcProxy.IAppService.DTOs.Outputs;
using SD.OpcProxy.ValueObjects.Enums;
using System;
using System.Collections.Generic;
using System.ServiceModel;

namespace SD.OpcProxy.IAppService.Interfaces
{
    /// <summary>
    /// OPC代理服务契约接口
    /// </summary>
    [ServiceContract(Namespace = "http://SD.OpcProxy.IAppService.Interfaces")]
    public interface IOpcProxyContract : IApplicationService
    {
        //命令部分

        #region # 创建OPC服务器 —— void CreateOpcServer(string opcServerName, OpcMode opcMode...
        /// <summary>
        /// 创建OPC服务器
        /// </summary>
        /// <param name="opcServerName">OPC服务器名称</param>
        /// <param name="opcMode">OPC模式</param>
        /// <param name="url">服务器地址</param>
        /// <param name="pingInterval">Ping间隔（单位：秒）</param>
        /// <param name="monitorInterval">监听间隔（单位：毫秒）</param>
        /// <param name="timeout">超时时间（单位：秒）</param> 
        [OperationContract]
        void CreateOpcServer(string opcServerName, OpcMode opcMode, string url, int pingInterval, int monitorInterval, int timeout);
        #endregion

        #region # 修改OPC服务器 —— void UpdateOpcServer(Guid opcServerId, string opcServerName...
        /// <summary>
        /// 修改OPC服务器
        /// </summary>
        /// <param name="opcServerId">OPC服务器Id</param>
        /// <param name="opcServerName">OPC服务器名称</param>
        /// <param name="url">服务器地址</param>
        /// <param name="pingInterval">Ping间隔（单位：秒）</param>
        /// <param name="monitorInterval">监听间隔（单位：毫秒）</param>
        /// <param name="timeout">超时时间（单位：秒）</param> 
        [OperationContract]
        void UpdateOpcServer(Guid opcServerId, string opcServerName, string url, int pingInterval, int monitorInterval, int timeout);
        #endregion

        #region # 删除OPC服务器 —— void RemoveOpcServer(Guid opcServerId)
        /// <summary>
        /// 删除OPC服务器
        /// </summary>
        /// <param name="opcServerId">OPC服务器Id</param>
        [OperationContract]
        void RemoveOpcServer(Guid opcServerId);
        #endregion

        #region # 创建变量 —— void CreateVariable(string variableNo, string variableName...
        /// <summary>
        /// 创建变量
        /// </summary>
        /// <param name="variableNo">变量编号</param>
        /// <param name="variableName">变量名称</param>
        /// <param name="variableType">变量类型</param>
        /// <param name="isReadonly">是否只读</param>
        /// <param name="dataType">数据类型</param>
        /// <param name="opcServerId">OPC服务器Id</param>
        /// <param name="unit">单位</param>
        /// <param name="keepRecord">是否记录历史</param>
        /// <param name="description">描述</param>
        /// <param name="valueDescriptions">值描述字典</param>
        [OperationContract]
        void CreateVariable(string variableNo, string variableName, VariableType variableType, bool isReadonly, string dataType, Guid opcServerId, string unit, bool keepRecord, string description, IDictionary<string, string> valueDescriptions);
        #endregion

        #region # 修改变量 —— void UpdateVariable(Guid variableId, string variableName...
        /// <summary>
        /// 修改变量
        /// </summary>
        /// <param name="variableId">变量Id</param>
        /// <param name="variableName">变量名称</param>
        /// <param name="opcServerId">OPC服务器Id</param>
        /// <param name="unit">单位</param>
        /// <param name="keepRecord">是否记录历史</param>
        /// <param name="description">描述</param>
        /// <param name="valueDescriptions">值描述字典</param>
        [OperationContract]
        void UpdateVariable(Guid variableId, string variableName, Guid opcServerId, string unit, bool keepRecord, string description, IDictionary<string, string> valueDescriptions);
        #endregion

        #region # 删除变量 —— void RemoveVariable(Guid variableId)
        /// <summary>
        /// 删除变量
        /// </summary>
        /// <param name="variableId">变量Id</param>
        [OperationContract]
        void RemoveVariable(Guid variableId);
        #endregion


        //查询部分

        #region # 分页获取OPC服务器列表 —— PageModel<OpcServerInfo> GetOpcServersByPage(string keywords...
        /// <summary>
        /// 分页获取OPC服务器列表
        /// </summary>
        /// <param name="keywords">关键字</param>
        /// <param name="pageIndex">页码</param>
        /// <param name="pageSize">页容量</param>
        /// <returns>OPC服务器列表</returns>
        [OperationContract]
        PageModel<OpcServerInfo> GetOpcServersByPage(string keywords, int pageIndex, int pageSize);
        #endregion

        #region # 分页获取变量列表 —— PageModel<VariableInfo> GetVariablesByPage(string keywords...
        /// <summary>
        /// 分页获取变量列表
        /// </summary>
        /// <param name="keywords">关键字</param>
        /// <param name="variableType">变量类型</param>
        /// <param name="isReadonly">是否只读</param>
        /// <param name="dataTypes">数据类型集</param>
        /// <param name="opcServerId">OPC服务器Id</param>
        /// <param name="keepRecord">是否记录历史</param>
        /// <param name="pageIndex">页码</param>
        /// <param name="pageSize">页容量</param>
        /// <returns>变量列表</returns>
        [OperationContract]
        PageModel<VariableInfo> GetVariablesByPage(string keywords, VariableType? variableType, bool? isReadonly, IList<string> dataTypes, Guid? opcServerId, bool? keepRecord, int pageIndex, int pageSize);
        #endregion

        #region # 是否存在OPC服务器地址 —— bool ExistsOpcServer(Guid? opcServerId, string url)
        /// <summary>
        /// 是否存在OPC服务器地址
        /// </summary>
        /// <param name="opcServerId">OPC服务器Id</param>
        /// <param name="url">服务器地址</param>
        /// <returns>是否存在</returns>
        [OperationContract]
        bool ExistsOpcServer(Guid? opcServerId, string url);
        #endregion

        #region # 是否存在变量编号 —— bool ExistsVariable(string variableNo)
        /// <summary>
        /// 是否存在变量编号
        /// </summary>
        /// <param name="variableNo">变量编号</param>
        /// <returns>是否存在</returns>
        [OperationContract]
        bool ExistsVariable(string variableNo);
        #endregion

        #region # 分页获取变量历史列表 —— PageModel<VariableHistoryInfo> GetVariableHistorysByPage(string keywords...
        /// <summary>
        /// 分页获取变量历史列表
        /// </summary>
        /// <param name="keywords">关键字</param>
        /// <param name="variableNo">变量编号</param>
        /// <param name="startTime">开始时间</param>
        /// <param name="endTime">结束时间</param>
        /// <param name="pageIndex">页码</param>
        /// <param name="pageSize">页容量</param>
        /// <returns>变量历史列表</returns>
        [OperationContract]
        PageModel<VariableHistoryInfo> GetVariableHistorysByPage(string keywords, string variableNo, DateTime? startTime, DateTime? endTime, int pageIndex, int pageSize);
        #endregion
    }
}
